<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="top">
        Search
    </ui:define>

    <ui:define name="left">
    </ui:define>



    <ui:define name="body">
        <h:form id="searchForm">
            <h:panelGrid columns="3" border="0">
                <h:outputLabel value="Name:"/>
                <h:inputText value="#{itemCTRL.sq.name}"/>
                <h:panelGroup/>
                <h:outputLabel value="Manufacturer:"/>
                <h:inputText value="#{itemCTRL.sq.manufacturer}"/>
                <h:panelGroup/>
                <h:outputLabel value="Stock Greater Than: "/>
                <h:inputText id="stock" validatorMessage="Only numbers, please!" value="#{itemCTRL.sq.stock}">
                    <f:validateRegex pattern="[0-9]*"/>
                </h:inputText>
                <h:message for="stock"/>
                <c:forEach var="i" begin="1" end="#{itemCTRL.noSearchAttributes}">
                    <h:selectOneMenu id="attribute${i}">
                        <c:forEach items="#{categoryCTRL.attributeList}" var="items">
                            <f:selectItem itemLabel="#{items.name}" itemValue="#{items.id}"/>
                        </c:forEach>
                    </h:selectOneMenu>
                    <h:inputText id="value${i}"/>
                    <h:panelGroup/>
                </c:forEach>
                <h:commandButton value="Search" action="#{itemCTRL.search}"/>
                <h:panelGroup/>
                <h:panelGroup/>
                <h:commandButton value="Add attribute" action="#{itemCTRL.addSearchAttribute}"/>
                <h:commandButton value="Remove attribute" action="#{itemCTRL.removeSearchAttribute}"/>
                
            </h:panelGrid>
        </h:form>
    </ui:define>

</ui:composition>
